package engine.tip.tipItem
{
	import engine.data.ObjectData;
	import engine.newUi.ComposeItemLogic;
	
	import newx.com.config.StaticIni;
	
	/**
	 *合成書 
	 * @author yanghr
	 * 
	 */	
	public class ComposeTipItem extends BaseTipItem
	{
		private var _material:Array;
		public function ComposeTipItem(dataObject:ObjectData=null, data:Object=null)
		{
			super(dataObject, data);
		}
		override public function getMainStr():String
		{
			return	getName()+getChangeLine()
				+	getQuality()
				+	getALine()
				+	getMaterial()
				+	getALine()
				+	getDescribe()
				+	getPrice()
				;
			
		}
		/**
		 *材料 
		 * @return 
		 * 
		 */		
		public function getMaterial():String
		{
			var obj:Object=StaticIni.getIniObj("ProduceItem_"+_data["ConfigID"]);
			var str:String=obj["r"];
			var arr:Array;
			arr=str.split(",");
			//去空格
			while(arr[arr.length-1]=="")
			{
				arr.pop();
			}
			var tips:String=""
			for (var i:int = 0; i <	arr.length; i+=2) 
			{
					tips	+=	getSingleMaterial(arr[i],arr[i+1]);
					tips	+=	(i%4)?getChangeLine():"      ";
			}
			if(tips)
				return tips+(i%4?getChangeLine():"");
			return ""
		}
		private function getSingleMaterial(materialID:int,totalCount:int):String
		{
			var name:String=StaticIni.getSwfLangStr(materialID+"");
			var currentCount:int=ComposeItemLogic.getInstance().searchItem(materialID,1);
			return link_color(name+currentCount+"/"+totalCount,(currentCount>=totalCount)?2:1)
		}
		/**
		 *品质 
		 * @return 
		 * 
		 */		
		public function getQuality():String
		{
			var tips:String	=	"";
			var color:String	=	_data["Color"];
			if(color)
			return StaticIni.getSwfLangStr("Color_" +color)+getChangeLine();
			return ""
		}
	}
}